package com.bang.study.config;

import com.bang.study.bean.Color;
import com.bang.study.bean.LifeCode;
import com.bang.study.bean.LifeCode02;
import com.bang.study.bean.Person;
import com.bang.study.condition.LinuxCondition;
import com.bang.study.condition.WindowsCondition;
import com.bang.study.filter.MyTypeFilter;
import com.bang.study.selector.MyFactoryBean;
import com.bang.study.selector.MyImportBeanDefinitionRegistrar;
import com.bang.study.selector.MyImportSelector;
import org.springframework.context.annotation.*;

/**
 * @Auther: Bang
 * @Date: 2020/7/29 22:47
 * @Description:
 * <p>
 *     配置类
 * </p>
 */
@Configuration
@Import({Color.class, MyImportSelector.class, MyImportBeanDefinitionRegistrar.class})
public class AppConfig2 {

    @Bean(value = "linux")
    @Conditional(value = LinuxCondition.class)
    public Person person02() {
       return new Person("linux", 18);
    }

    @Bean("windows")
    @Conditional(value = WindowsCondition.class)
    public Person person01() {
        return new Person("windows", 18);
    }


    @Bean
    public MyFactoryBean myFactoryBean() {
        return new MyFactoryBean();
    }

    /*@Bean(initMethod = "init",destroyMethod = "destory")
    public LifeCode lifeCode() {
        return new LifeCode();
    }
*/
    @Bean(initMethod = "init",destroyMethod = "destory")
    public LifeCode02 lifeCode02() {
        return new LifeCode02();
    }


}
